package sealte.wdgf.utils;

import java.io.File;

import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.input.SAXBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class XMLBaseObject {
	
	private Document doc;
	private Element root;
	private static Logger logger = LoggerFactory.getLogger(XMLBaseObject.class);
	
	public XMLBaseObject(File file){
		SAXBuilder sb = new SAXBuilder();
		try {
			doc = sb.build(file);
		} catch (Exception e) {
			logger.error("创建XMLbaseObject对象时出错！原因："+e.getMessage());
		} 
		root = doc.getRootElement();
	}
	
	public XMLBaseObject(String xmlString){
		SAXBuilder sb = new SAXBuilder();
		try {
			doc = sb.build(xmlString);
		} catch (Exception e) {
			logger.error("创建XMLbaseObject对象时出错！原因："+e.getMessage());
		}
		root = doc.getRootElement();
	}
	
	public Element getRoot(){
		return root;
	}
	
	public Document getDoc(){
		return doc;
	}
}
